package com.stephenone.jetpackdemo;

import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

/**
 * Created by wenzhubin on 2020-03-27.
 */
public class MyViewModel extends ViewModel {
    private MutableLiveData<Integer> likedNumber;

    public MutableLiveData<Integer> getLikedNumber() {
        if (likedNumber == null) {
            likedNumber = new MutableLiveData<>();
            likedNumber.setValue(0);
        }
        return likedNumber;
    }


    public void addLikedNumber(int n){
        likedNumber.setValue(likedNumber.getValue() + n);
    }


}
